package club.caihappy.service.impl;

import club.caihappy.constants.SystemConstants;
import club.caihappy.domain.ResponseResult;
import club.caihappy.domain.entity.Link;
import club.caihappy.domain.vo.LinkVO;
import club.caihappy.mapper.LinkMapper;
import club.caihappy.service.LinkService;
import club.caihappy.utils.BeanCopyUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 友链(Link)表服务实现类
 *
 * @author makejava
 * @since 2022-11-02 15:07:19
 */
@Service("linkService")
public class LinkServiceImpl extends ServiceImpl<LinkMapper, Link> implements LinkService {

    @Override
    public ResponseResult getAllLink() {
        //查询所有审核通过的
        List<Link> list = list(new LambdaQueryWrapper<Link>().eq(Link::getStatus, SystemConstants.LINK_STATUS_NORMAL));
        //转换成VO
        List<LinkVO> linkVOS = BeanCopyUtils.copyBeanList(list, LinkVO.class);
        return ResponseResult.okResult(linkVOS);
    }
}
